<?php if (!defined('THINK_PATH')) exit();?><style type="text/css">
	.page-shopping .bottom-panel{display: flex;}
	.page-shopping .bottom-panel .info{margin-top:10px;width: 50%; padding-right:10px;}
	.page-shopping .bottom-panel .right{margin-top: 10px;}
  .page-shopping .item-list .attr span{overflow: hidden;display: -webkit-box; font-weight: normal; white-space: nowrap;}
</style>
 <?php if(is_array($cartList)): foreach($cartList as $k=>$v): ?><div  class="block" style="margin-top:0px;">
      <input type="hidden" name="supplierid" id="supplierid" value="7">
      <div class="item-list">
       <div class="item">
         <div class="inner">
           <div style="width:60%; float:left; height:80px;">
             <div class="check-wrapper">
              <span  class="cart-checkbox  <?php if($v[selected] == 1): ?>checked<?php endif; ?>">
                 <input type="checkbox" autocomplete="off" name="cart_select[<?php echo ($v["id"]); ?>]" <?php if($v[selected] == 1): ?>checked="checked"<?php endif; ?>  style="display:none;" value="1" onclick="ajax_cart_list();">
              </span>
             </div>
             <div  class="pic">
                 <a href="<?php echo U('Mobile/Goods/goodsInfo',array('id'=>$v[goods_id]));?>"><img src="<?php echo (get_goods_images($v["goods_id"])); ?>"></a>
             </div>
             
             <div class="name">
               <span>  <?php echo ($v["goods_name"]); ?> </span>
                 <?php if($v[spec_key_name]): ?><span>课程数：<?php echo (orderdetailstr($v["spec_key_name"])); ?> 节</span><?php endif; ?>
             </div>
             <div class="attr">
                 <span><?php echo ($v["spec_key_name"]); ?></span>
             </div>
              <div class="num" style="display: none">
                 <div class="xm-input-number">
                   <div class="act_wrap">
                        <a href="javascript:;" onclick="switch_num(-1,<?php echo ($v["id"]); ?>,<?php echo ($v["store_count"]); ?>);" id="jiannum6" class="input-sub active"></a>
                     	<input id="goods_num[<?php echo ($v["id"]); ?>]" type="text" onKeyDown='if(event.keyCode == 13) event.returnValue = false' name="goods_num[<?php echo ($v["id"]); ?>]"  value="<?php echo ($v["goods_num"]); ?>"  class="input-num"  onblur="ajax_cart_list()"/>
                     	<a href="javascript:;" onclick="switch_num(1,<?php echo ($v["id"]); ?>,<?php echo ($v["store_count"]); ?>);"  class="input-add active"></a>
                     </div>
                  </div>                 
             </div>
           </div>
           <div style=" position:absolute; right:0px; top:15px; width:100px; height:80px;">
             <div class="price"> <span>￥<?php echo ($v["goods_price"]); ?></span>
               <!--<span class="mar_price">￥<?php echo ($v["market_price"]); ?></span>-->
               <br>
              
              </div>
             <div class="delete">
               <a href="javascript:void(0);" onclick="del_cart_goods(<?php echo ($v["id"]); ?>)">
                <i class="icon iconfont icon-yydelete2"></i>
               </a>
             </div>
           </div>
           <div style="height:0px; line-height:0px; clear:both;"></div>
         </div>
         <div class="append"></div>
       </div>
     </div>
    </div><?php endforeach; endif; ?>
<?php if(empty($cartList)): ?><div class="screen-wrap fullscreen login">
<section id="cart-content">
      <div class="qb_tac" style="padding:50px 0">
        <img src="/Template/mobile/new/Static/images/flow/empty_cart.png" width="170" >
        <br>购物车暂无商品</div>
      <div class="qb_gap" style="width:60%; margin:0 auto;">
        <a href="<?php echo U('Goods/categoryList');?>" class="mod_btn btn_strong"><i class="icon iconfont icon-paobu fontbao"></i>去商城逛逛</a>
      </div>
</section>
<div style="height:72px;"></div>
<section class="f_mask" style="display: none;"></section>
<section class="f_block" id="choose" style="height:0px;"></section> 
</div>
 <?php else: ?>
	 <div class="bottom-panel">
	    <div class="quanxuan">
	     <div class="check-wrapper">
	        <span class="cart-checkbox" onclick="chkAll_onclick()"></span><span class="cart-checktext">全选</span>
	     </div>
	   </div>
	   <div class="info">
	     <span class="hot" id="cart_amount_desc"><em>合计：</em>￥<?php echo ($total_price["total_fee"]); ?></span>

	   </div>
	   <div class="right">
	     <input type="button" href="javascript:void();"  onclick="return selcart_submit();" class="xm-button " value="去结算"></div>
	</div><?php endif; ?> 
<script type="text/javascript">
$(".check-wrapper .cart-checkbox").click(function(){
	if($(this).hasClass('checked')){
		$(this).removeClass('checked');
		$(this).find('input').attr('checked',false);
	}else{
		$(this).addClass('checked');
		$(this).find('input').attr('checked',true);
	}
	ajax_cart_list();
})

var is_checked = true;
$('.inner .cart-checkbox').each(function(){
	  if(!$(this).hasClass('checked'))
	  {
	       is_checked = false;
	       return false;
	  }
});
if(is_checked){
  	$('.quanxuan .cart-checkbox').addClass('checked'); 
}else
{
  	$('.quanxuan .cart-checkbox').removeClass('checked'); 
} 
	
function chkAll_onclick() 
{
  if($('.quanxuan .cart-checkbox').hasClass('checked')){	  
    $('.quanxuan .cart-checkbox').removeClass('checked');
    $('.inner .cart-checkbox').removeClass('checked');
    $("input[name^='cart_select']").prop('checked',false);
    is_checked = false;
  }   
  else{
    $('.quanxuan .cart-checkbox').addClass('checked');
    $('.inner .cart-checkbox').addClass('checked');
    $("input[name^='cart_select']").prop('checked',true);
    is_checked = true;
  }
  ajax_cart_list();
}

function del_cart_goods(goods_id)
{
    if(!confirm('确定要删除吗?'))
        return false;
    var chk_value = [];
    chk_value.push(goods_id);
    // ajax调用删除
    if(chk_value.length > 0)
        ajax_del_cart(chk_value.join(','));
}


function selcart_submit()
{
     var j=0;
	 $('input[name^="cart_select"]:checked').each(function(){
	       j++;
	 });
     if (j>0)
     {
		  window.location.href="<?php echo U('Mobile/Cart/cart2');?>"
     }
     else
     {   
	     alert('请选择要结算的商品！');
	     return false;
    }
}
</script>
<?php if(empty($cartList)): ?><div class="v_nav">
	<div class="vf_nav">
		<ul>

			<li> <a href="<?php echo U('Mobile/Index/index');?>" <?php if($navid == 'home'): ?>class="act"<?php endif; ?> >
			    <i class="icon iconfont icon-shouye"></i>
			    <span>首页</span></a></li>

           	<?php if($_SESSION[is_coach]!=1){ ?>
                <li><a href="<?php echo U('Goods/categoryList');?>" <?php if($navid == 'shop'): ?>class="act"<?php endif; ?> >
                    <i class="icon iconfont icon-paobu fontbao"></i>
                    <span>商城</span></a></li>
                    
                <li><a href="<?php echo U('Coach/coach_list');?>" <?php if($navid == 'coach'): ?>class="act"<?php endif; ?> >
                    <i class="icon iconfont icon-juzhong"></i>
                    <span>教练</span></a></li>
                <li><a href="<?php echo U('Cart/cart');?>" <?php if($navid == 'cart'): ?>class="act"<?php endif; ?> >
                    <i class="icon iconfont icon-gouwuche fontshop"></i>
                    <span>购物车</span></a></li>
            <?php } ?>
           
			<!--<li>-->
			<!--<a href="<?php echo U('Cart/cart');?>">-->
			   <!--<em class="global-nav__nav-shop-cart-num" id="cart_quantity" style="right:9px;"></em>-->
			   <!--<i class="vf_4"></i>-->
			   <!--<span>购物车</span>-->
			   <!--</a>-->
			<!--</li>-->
			<?php if($_SESSION['is_coach']){ ?>
			<li><a href="<?php echo U('Yuyue/coach_detail');?>" <?php if($navid == 'yuyue'): ?>class="act"<?php endif; ?> >
			    <i class="icon iconfont icon-calendar"></i>
				<span>预约</span></a>
			</li>
			<?php }else{ ?>
			<li style="display:none;"><a href="<?php echo U('Yuyue/coach_list');?>" <?php if($navid == 'yuyue'): ?>class="act"<?php endif; ?>  >
			    <i class="icon iconfont icon-calendar"></i>
				<span>预约</span></a>
			</li>
			<?php } ?>


			<!--<li><a href="<?php echo U('Yuyue/coach_list');?>">-->
				<!--<i class="vf_5"></i>-->
				<!--<span>预约</span></a>-->
			<!--</li>-->
			<li><a href="<?php echo U('User/index');?>" <?php if($navid == 'user'): ?>class="act"<?php endif; ?>>
			    <i class="icon iconfont icon-gerenzhongxin"></i>
			    <span>我的</span></a>
			</li>
		</ul>
	</div>
</div> 
<script type="text/javascript">
$(document).ready(function(){
	  var cart_cn = getCookie('cn');
	  if(cart_cn == ''){
		$.ajax({
			type : "GET",
			url:"/index.php?m=Home&c=Cart&a=header_cart_list",//+tab,
			success: function(data){								 
				cart_cn = getCookie('cn');
				$('#cart_quantity').html(cart_cn);						
			}
		});	
	  }
	  $('#cart_quantity').html(cart_cn);
});
</script>

<?php if($_GET[act] == 1): ?><script>
    XBack = {};

    (function(XBack) {
        XBack.STATE = 'x - back';
        XBack.element;

        XBack.onPopState = function(event) {
            event.state === XBack.STATE && XBack.fire();
            XBack.record(XBack.STATE); //初始化事件时，push一下
        };

        XBack.record = function(state) {
            history.pushState(state, null, location.href);
        };

        XBack.fire = function() {
            var event = document.createEvent('Events');
            event.initEvent(XBack.STATE, false, false);
            XBack.element.dispatchEvent(event);
        };

        XBack.listen = function(listener) {
            XBack.element.addEventListener(XBack.STATE, listener, false);
        };

        XBack.init = function() {
            XBack.element = document.createElement('span');
            window.addEventListener('popstate', XBack.onPopState);
            XBack.record(XBack.STATE);
        };

    })(XBack); // 引入这段js文件

    XBack.init();
    XBack.listen(function() {});
</script><?php endif; ?>
<!-- 微信浏览器 调用微信 分享js-->
<?php if($signPackage != null): endif; ?>
<!-- 微信浏览器 调用微信 分享js  end--><?php endif; ?>